﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Common;
using Model;

namespace CodeFactory
{
    public partial class InheritItemCreater : Form
    {
        private CustomPropertyGrid cpg;
        public InheritItemCreater()
        {
            InitializeComponent();
        }

        public InheritItemCreater(CustomPropertyGrid _cpg)
        {
            InitializeComponent();
            cpg = _cpg;
        }
        

        private void ComboBoxBind()
        {
            foreach(string s in Enum.GetNames(typeof(enumInheritType)))
            {
                cmbType.Items.Add(s);
            }
            cmbType.SelectedIndex = 0;
            
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            eInherit ei=new eInherit();
            ei.Name=txtName.Text.Trim();
            ei.Type=(enumInheritType)Enum.Parse(typeof(enumInheritType),cmbType.SelectedItem.ToString(),false);
            cpg.AddInheritItemToTree(ei);
            Close();
        }

        private void InheritItemCreater_Load(object sender, EventArgs e)
        {
            ComboBoxBind();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            Close();
        }
    }
}
